 var infowindow;
 var mapCom;
 var baseURL ="https://labs.commutegreenerinfo.com/it/";
 function initializeFothMap() {
	  
//   var myLatlng = new google.maps.LatLng(57.70779280783442, 11.937975883483887);
//   var myOptions = {
//     zoom: 10,
//     center: myLatlng,
//     mapTypeId: google.maps.MapTypeId.ROADMAP
//   }
//   
//  
//   mapCom = new google.maps.Map(document.getElementById("map_previous"), myOptions);

	    var myOptions1 = {
				center : new google.maps.LatLng(57.70779280783442, 11.937975883483887),
				zoom : 9,
				mapTypeId : google.maps.MapTypeId.ROADMAP
			};
			//gothenburg center
			var myOptions2 = {
				center : new google.maps.LatLng(19.429413676234212, -99.12683863302618),
				zoom : 9,
				mapTypeId : google.maps.MapTypeId.ROADMAP
			};
			
		
			
			 if(document.getElementById("citymapPrev").value == "mexico"){
				 mapCom = new google.maps.Map(document.getElementById("map_previous"), myOptions2);
					
			  }else if(document.getElementById("citymapPrev").value == "gothenborg"){
				  mapCom = new google.maps.Map(document.getElementById("map_previous"), myOptions1);
				  
			  }
   downloadUrl("js/startLocation.xml", function(data) {
   	//"js/moredata.xml"  "js/Location.xml"  C:/files/Location.xml
     var markers = data.documentElement.getElementsByTagName("marker");
     for (var i = 0; i < markers.length; i++) {
       var latlng = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
                                   parseFloat(markers[i].getAttribute("lng")));
       var marker = createMarkerCom(markers[i].getAttribute("name"), latlng);
      }
    });
   $('#auto-button').hide(); 
   $('#auto-button').trigger('onclick');
  
 }
 
 
 
// function createMarkerCom(name, latlng) {
//	    var marker = new google.maps.Marker({position: latlng, map: mapCom});
//	    google.maps.event.addListener(marker, "click", function() {
//	      if (infowindow) infowindow.close();
//	      infowindow = new google.maps.InfoWindow({content: name});
//	      infowindow.open(mapCom, marker);
//	    });
//	    
//	    if(name =="BUS"){
//	    	iconFile = 'images/black.png'; 
//	    }
//	    else if(name =="CAR"){
//	    	iconFile = 'images/red.png'; 
//	    }
//	    else if(name =="BICYCLE"){
//	    	iconFile = 'images/green.png'; 
//	    }
//	    else if(name =="WALKING"){
//	    	iconFile = 'images/yellow.png'; 
//	    }
//	    else if(name =="FERRY"){
//	    	iconFile = 'images/blue.png'; 
//	    }
//	    else if(name =="TRAIN_SUBWAY_METRO"){
//	    	iconFile = 'images/pink.png'; 
//	    }
//	    else if(name =="AEROPLANE"){
//	    	iconFile = 'images/silver.png'; 
//	    }
//	    else if(name =="DESTINATION"){
//	    	iconFile = 'images/check_flag.png'; 
//	    }
//	    
//	    marker.setIcon(iconFile) ;
//	    return marker;
//	  }
 
 function createMarkerCom(name, latlng) {

		var iconFile;
		if (name == "BUS") {
			iconFile = "images/black.png";
		} else if (name == "CAR") {
			iconFile = 'images/red.png';
		} else if (name == "BICYCLE") {
			iconFile = 'images/green.png';
		} else if (name == "WALKING") {
			iconFile = 'images/purple.png';
		} else if (name == "FERRY") {
			iconFile = 'images/blue.png';
		} else if (name == "TRAIN_SUBWAY_METRO") {
			iconFile = 'images/pink.png';
		} else if (name == "AEROPLANE") {
			iconFile = 'images/silver.png';
		}
	    else if(name =="DESTINATION"){
	    	iconFile = 'images/check_flag.png'; 
	    }
	  	
	  	var marker = new google.maps.Marker({
	  		position : latlng,
	  		map : mapCom,
	  		icon : baseURL+iconFile
	  	});

//	  	google.maps.event.addListener(marker, "click", function() {
//	  		if (infowindow1)
//	  			infowindow.close();
//	  		infowindow1 = new google.maps.InfoWindow({
//	  			content : name
//	  		});
//	  		infowindow1.open(map1, marker);
//	  	});
	  	
	  	 google.maps.event.addListener(marker, "click", function() {
		      if (infowindow) infowindow.close();
		      infowindow = new google.maps.InfoWindow({content: name});
		      infowindow.open(map, marker);
		    });
	  	
	  	
	  }
 